package two;

public class SubtractExpression extends AbstractExpression {
    public SubtractExpression(int num1, int num2) {
        super(num1, num2);
    }

    @Override
    public int calculate() {
        return Math.max(num1, num2) - Math.min(num1, num2); // 结果非负
    }

    @Override
    public String toString() {
        // 确保被减数 >= 减数，格式化显示
        int max = Math.max(num1, num2);
        int min = Math.min(num1, num2);
        return max + " - " + min + " = " + result;
    }
}